<!--<?php
print <<<EOT
-->
<div class="m"></div>
<!--
EOT;
if(!$this->cid){
print <<<EOT
-->
<form action="$basename" method="post">
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="head">
    <td colspan="2">请选择您要发布{$very[contentName]}的目录</td>
    </tr>
  <tr class="line">
    <td>&nbsp;</td>
    <td><select name="cid" id="cid">
	请选择目录
	$cate_select
    </select>
    </td>
  </tr>
  <tr class="line">
    <td colspan="2">&nbsp;</td>
    </tr>
</table>
</div>
<div class="sub">
<input name="" type="submit" value="提交" class="btn" />
</div>
</form>
<!--
EOT;
}else{
print <<<EOT
-->
<style>
.menu{position:absolute;background:#fff;border:1px solid #69788c;}
.menu td, .menu li{background:#e6f5ff;}
.menu li{list-style:none;padding:0;}
.menu a{display:block;padding:3px 15px 3px 15px}
.menu a:hover{background:#e6f5ff;text-decoration:none;color:#fff;}
.menu ul.ul1 li a{display:inline;padding:0} 
#colorbox{width:91px;height:78px;padding:3px 0 0 3px;overflow:hidden;}
#colorbox div{cursor:pointer;width:8px;height:8px;float:left;margin:0 3px 3px 0;border:1px #000 solid;font:0/8px arial}
</style>
<div class="menu" id="menu_editor" style="display:none;"></div>
<div id="showmenu" style="z-index:100;display:none;"></div> 
<script language="javascript" src="script/global.js"></script>
<script language="javascript" src="script/xhr.js"></script>
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="tr4">
    <td>目录切换&nbsp;&nbsp;&nbsp;
        <select name="menu1" onchange="window.location='$basename&cid='+this.value;">
		$cate_select
	    </select>
		<input type="button" name="Submit5" value="设置本目录" class="btn" onclick="window.location='$admin_file?adminjob=category&action=edit&action=edit&cid=$cid';"/>
		<input type="button" value="查看目录下所有{$very[contentName]}" class="btn" onclick="window.location='$admin_file?adminjob=content&action=view&cid=$cid';" />
      </td>
  </tr>
</table>
</div>
<script language="javascript">
var action = 'add';
var tid = '$tid';
<!--
EOT;
if($action=='edit'){
print <<<EOT
-->
	var action = 'edit';
<!--
EOT;
}print <<<EOT
-->
var resNum = 1;
var minNum = 1;

function addRes()
{
	resNum++;
	var inputTable = document.getElementById('resource');
	var newTr = document.createElement('tr');
	newTr.id = 'resTr' + resNum;
	newTr.className = 'line';
	var newTd1 = document.createElement('td');
	var newTd2 = document.createElement('td');
	var newTd3 = document.createElement('td');
	//var newTd4 = document.createElement('td');
	newTr.appendChild(newTd1);
	newTr.appendChild(newTd2);
	//newTr.appendChild(newTd4);
	newTr.appendChild(newTd3);
	inputTable.appendChild(newTr);
	newTd1.innerHTML = resNum + '.';
	newTd2.innerHTML = '<input type="text" name="restitle[' + resNum + ']" id="title' + resNum + '" class="input" size="40" />'
	newTd3.innerHTML = '<input type="file" name="file' + resNum + '" class="input" id="file' + resNum + '" size="60" />';
	//newTd4.innerHTML = '<td><input type="checkbox" name="reszip[' + resNum + ']" id="zip' + resNum + '" /></td>'
}

function delRes()
{
	if(resNum == minNum) return false; //已经到达了最小数字，不可能再删除了。
	var inputTable = document.getElementById('resource');
	var resTr = document.getElementById('resTr'+resNum);
	inputTable.removeChild(resTr);
	resNum--;
}

var prepare = false;
/* 判断上传的有效性 */
function checkUpload()
{
	//var UPLOAD = document.getElementById('UPLOAD');
	var uploadNum = 0;
	for (var i=1; i <= resNum; i++)
	{
		if(document.getElementById('file'+i).value != '')
		{
		/*
			if(document.getElementById('zip'+i).checked)
			{
				alert(document.getElementById('file'+i).value);
			}
		*/
		/*
			if( document.getElementById('title'+i).value.length == 0 )
			{
				if(resNum == 1)
				{
					document.getElementById('title'+i).value = document.getElementById('title').value; //这种情况下就让资源标题等于{$very[contentName]}标题
					return true;
				}
				else
				{
					alert('错误: 第' + i +'条信息没有填写资源标题！');
					document.getElementById('title'+i).focus();
					return false;
				}
			}
			else
			{
				uploadNum++;
			}
			*/
			uploadNum++;
		}
	}
	if (action == 'add' && uploadNum == 0) 
	{
		alert('您没有上传任何文件，请选择上传本{$very[contentName]}下的文件资源！');
		return false;
	}
	return true;
	//UPLOAD.submit();
}
function checkRes()
{
	if(document.getElementById('title').value.length < 2)
	{
		alert('{$very[contentName]}标题为空或者长度小于2，请务必填写此项。');
		document.getElementById('title').focus();
		return false;
	}
	return checkUpload();
}

var removeRid = '';
function removeRes(rid)
{
	var con = confirm("您确认要从本{$very[contentName]}中移除此资源么？");
	if(!con) return false;
	var xhr = new XHR('removeRes2');
	var url = '$basename&action=removeRes&rid='+rid + '&tid=' + tid;
	//alert(url);
	xhr.get(url);
	removeRid = rid;
}

function removeRes2(msg)
{
	//alert(msg);
	if(msg == 1)
	{
		var inputTable = document.getElementById('resource');
		var resTr = document.getElementById('res_'+removeRid);
		inputTable.removeChild(resTr);
	}
}
</script>
<iframe name="uploadFrame" width="0" height="0" style="visibility:hidden"></iframe>
<form action="$basename" method="post" name="FORM" enctype="multipart/form-data" onsubmit="return checkRes();">
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody id="resource">
  <tr class="head">
    <td colspan="3">
<span style="float:right"> <a href="javascript:void(0);" onclick="addRes();"><img src="images/admin/down.gif" alt="上传更多资源" hspace="5" /></a> <a href="javascript:void(0);" onclick="delRes();"><img src="images/admin/up.gif" alt="缩减" hspace="5" /></a></span>	
	$catename 
<!--
EOT;
if($action=='add'){
print <<<EOT
-->
	添加资源
<!--
EOT;
}elseif($action=='edit'){
print <<<EOT
-->
	编辑资源
<!--
EOT;
}print <<<EOT
-->（如果您同时需要上传大量文件，请使用前台的超级上传）</td>
  </tr>
  <tr class="tr2">
    <td width="5%">&nbsp;</td>
    <td width="35%" style="text-align:center">资源说明
      <input name="action" type="hidden" id="action" value="uploadRes" /></td>
    <td width="60%" style="text-align:center">选择文件</td>
  </tr>
<!--
EOT;
if($action=='edit'){
foreach($res as $r){
print <<<EOT
-->
  <tr class="line" id="res_{$r[rid]}">
  	<td> <img src="images/admin/res.png" /> </td>
    <td>$r[filetitle]</td>
	<td colspan="2">
	<span class="fr">
	<a href="javascript:void(0);" onclick="removeRes('$r[rid]');"><img src="images/admin/delete.png" align="absmiddle" title="删除此资源" /></a></span>
	$r[filepath]</td>
  </tr>	
<!--
EOT;
}}print <<<EOT
-->
  <tr class="line">
    <td>1.</td>
    <td><input type="text" name="restitle[1]" id="title1" class="input" size="40" /></td>
    <td><input type="file" name="file1" class="input" id="file1" size="60" /></td>
  </tr>
</tbody>
</table>
</div>
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="head">
    <td colspan="2">$catename 
<!--
EOT;
if($action=='add'){
print <<<EOT
-->
	添加资源描述
<!--
EOT;
}elseif($action=='edit'){
print <<<EOT
-->
	编辑资源描述
<!--
EOT;
}print <<<EOT
-->	</td>
    </tr>
  <tr class="tr2">
    <td width="15%" style="text-align:center">字段名</td>
    <td width="85%" style="text-align:center">{$very[contentName]}</td>
  </tr>
<!--
EOT;
foreach($inputArea as $value){
print <<<EOT
-->
  <tr class="line">
    <td>$value[fieldname]</td>
    <td>$value[input]</td>
  </tr>
<!--
EOT;
}print <<<EOT
-->
  <tr class="line">
    <td>当前Tags</td>
    <td><span style="float:right; padding-right:100px;">点击可删除或编辑关键字</span><input name="tagsid" type="hidden" value=",$tagsid" /><span id='tags_show'>$tags </span></td>
  </tr>
  <tr class="line">
    <td>关键字管理</td>
    <td>
		<span style="float:right; padding-right:100px;">多TAG可用空格区分一次添加</span>
			<input type="text" name="tags" id="tags" class="input" size="40" onkeyup="SearchTag(event);" />
			<input type="button" name="Submit3" value="添加关键字" class="btn" onclick="addtag();" />
			<div id="showtags" class="showtags"></div></td>
  </tr>
</table>
</div>
<div class="sub">
  <input name="step" type="hidden" id="step" value="2" />
  <input name="aid" type="hidden" id="aid" value="$aids" />
  <input name="tid" type="hidden" id="tid" value="$tid" />
  <input name="action" type="hidden" id="action" value="$action" />
  <input type="submit" name="Submit" value="提交" class="btn" />
  <input type="reset" name="Submit2" value="重置" class="btn" />
</div>
</form>
<script language="javascript">
function IsBrowser(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	// Internet Explorer
	if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
		return "msie" ;

	// Gecko (Opera 9 tries to behave like Gecko at this point).
	if ( navigator.product == "Gecko" && !( typeof(opera) == 'object' && opera.postError ) )
		return "gecko";

	// Opera
	if ( navigator.appName == 'Opera')
		return "opera" ;

	// Safari
	if ( sAgent.indexOf( 'safari' ) != -1 )
		return "safari";

	return false ;
}

function selectImg(inputname){
	if(IsBrowser()=='msie'){
		showModalDialog("$basename&action=addimage&inputtype=input&inputname="+inputname,window,'dialogWidth=650px;dialogHeight=500px;help:no;status:no;');
	}else{
		window.open("$basename&action=addimage&inputtype=input&inputname="+inputname,'','width=650,height=500,status=no');
	}
}
var tagid = document.FORM.tagsid;
var tagname;
var tags;
function SelectTag(tag,id){
	tagname = tag;
	var newid = parseInt(id);
	if(tagid.value.indexOf(newid)=='-1'){
		tagid.value+=newid+',';
		document.getElementById('tags_show').innerHTML+="<A href=\"javascript:deltag("+newid+",'"+tagname+"');\">"+tagname+"</A>   ";
	}
}

function SearchTag(evt){
	e=catchKeyCode(evt);
	if(e==13){
		addtag();
	}else{
		tagname = document.FORM.tags.value;
		tagname=tagname.replace(/(^\s*)|(\s*$)/g, "").replace(/\s+/g," ");
		tags = tagname.split(" ");
		if(tags[tags.length-1].length>0){
			var xhr = new XHR('ShowSearchTag');
			var url = '$basename&action=SearchTag&tagname='+encodeURI(tags[tags.length-1]);
			xhr.get(url);
		}else{
			document.getElementById('showtags').style.display ='none';
		}
	}
}

function ShowSearchTag(ret){
	var st = document.getElementById('showtags');
	if(ret!='error'){
		st.innerHTML=ret;
		st.style.display ='block';
	}else{
		st.innerHTML='';
		st.style.display ='none';
	}
}

function catchKeyCode(evt){
	evt=window.event||evt;
	var ret=evt.keyCode?evt.keyCode:evt.which;
	return ret;
}

function addtag(){
	var j=0;
	tagname = document.FORM.tags.value;
	tagname=tagname.replace(/(^\s*)|(\s*$)/g, "").replace(/\s+/g," ");
	tags = tagname.split(" ");
	for(i in tags){
		if(tags[i].length<=1){
			alert('每一个标签(tag)必须由两个以上的字符组成');
			return false;
		}
	}
	var xhr = new XHR('showtag');
	var url = '$basename&action=tags&tagname='+encodeURI(tagname);
	xhr.get(url);
}

function showtag(ret){
	var newid = ret.split(',');
	for(i in tags){
		if(tagid.value.indexOf(newid[i]+',')=='-1'){
			tagid.value+=newid[i]+',';
			var browser = IsBrowser();
			document.getElementById('tags_show').innerHTML+="<A href=\"javascript:deltag("+newid[i]+",'"+tags[i]+"');\">"+tags[i]+"</A>   ";
			document.FORM.tags.value='';
		}
	}
}

function deltag(id,tagname){
	var ss=id+',';
	var nn;
	var browser = IsBrowser();
	if(browser=='msie' || browser=='opera'){
		nn="<A href=\"javascript:deltag("+id+",'"+tagname+"');\">"+tagname+"</A>";
	}else{
		nn="<a href=\"javascript:deltag("+id+",'"+tagname+"');\">"+tagname+"</a>";
	}
	var valueNow = tagid.value.replace(ss,' ');
	var tagNow = document.getElementById('tags_show').innerHTML.replace(nn,' ');
	document.getElementById('tags_show').innerHTML = tagNow;
	tagid.value=valueNow;
	document.FORM.tags.value=tagname;
}

function selectValue(inputname,value){
	if(value!=''){
		document.getElementById(inputname).value=value;
	}
}

function showColor(showName,inputName){
	var menu_editor = getObj("menu_editor");
	var colors = [
		'000000','660000','663300','666600','669900','66CC00','66FF00','666666','660066','663366','666666',
		'669966','66CC66','66FF66','CCCCCC','6600CC','6633CC','6666CC','6699CC','66CCCC','66FFCC','FF0000',
		'FF0000','FF3300','FF6600','FF9900','FFCC00','FFFF00','0000FF','FF0066','FF3366','FF6666','FF9966',
		'FFCC66','FFFF66','00FFFF','FF00CC','FF33CC','FF66CC','FF99CC','FFCCCC','FFFFCC'
	];
	var html = '<div id="colorbox">';
	for(i in colors){
		html += "<div unselectable=\"on\" style=\"background:#" + colors[i] + "\" onClick=\"SetC('" + colors[i] + "','" + inputName + "')\"></div>";
	}
	html += '</div>';
	menu_editor.innerHTML = html;
	if(typeof type == 'undefined'){
		click_open('menu_editor',showName,'2');
	} else{
		mouseover_open('menu_editor',showName,'2');
	}
}
function SetC(color,inputName){
	//var textValue = document.getElementById(inputName).value;
	//document.getElementById(inputName).value = "<span style=\"color:#"+color+";\">"+textValue+"</span>";
	document.getElementById(inputName).value = "#"+color;
	closep();
}

</script>
<!--
EOT;
}?>-->